home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000064_icon-group-sender _Mon Mar 3 15:03:06 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Received: by cheltenham.cs.arizona.edu; Tue, 4 Mar 1997 08:23:18 MST
To: icon-group@cs.arizona.edu
Date: Mon, 03 Mar 1997 15:03:06 -0700
From: Steve Wampler <swampler@gemini.edu>
Message-Id: <331B4A9A.4C37@gemini.edu>
Organization: Gemini 8m Telescopes Project
Sender: icon-group-request@cs.arizona.edu
References: <5ff37v$r3n$1@gaia.ns.utk.edu>
Subject: Re: reading reals
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1015
Mark Kot wrote:
>
> What is the Icon analog to the C
> programming instruction
>
> scanf("%f%f", &x, &y); ?
>
> That is, what is the simplest (or most standard)
> way to read two real numbers (with intervening
> and/or preceding white space) from a line of
> input in Icon ?
Hmmm, 'simplest' is interesting. I assume you really
mean %f, and not %g, and that you're happy with pretty
simple error checking. Here's one approach:
procedure main()
every line := !&input do {
line ? {
x := get_real() | write(&errout, "Bad real: ",&subject)
y := get_real() | write(&errout, "Bad real: ",&subject)
}
write("x = ", x)
write("y = ", y)
}
end
procedure get_real()
static digitseq
initial digitseq := '+-.' ++ &digits
suspend real( (tab(upto(digitseq)), tab(many(digitseq))) )
end
--
Steve Wampler - swampler@gemini.edu [Gemini 8m Telescopes Project (under
AURA)]
The Gods that smiled upon your birth are laughing now. -- fortune cookie